* all
  * virtualbox
    * 2 CPUs (or 3)
      \ because I'm unsure if 4 CPU is actually really slowing it down or just very very slightly faster
    * PAE/NX
    * KVM
    * Enable Nested Paging
    * point to the ISO, don't selecct Live CD/DVD
    * Controller: SATA, select Use Host I/O Cache
    * vdi select Solid-state Drive, not Hot-pluggable
    * Network is already NAT
    * Enable Serial Port 1, COM1, Raw File, /tmp/nixos_test1.log
    * add shared folder and Folder Name it as: vmsharedfolder
      \ select Auto Mount
  * cfdisk
    \ nothing needs to be set bootable!
    * gpt
    * swap xG where x is ammount of RAM * 3/2
    * 1M Bios Boot (for grub, since this is gpt)
    * rest for Linux
  * make filesystems
    * mkswap -L myswap /dev/sda1
    * mkfs.btrfs -L myroot /dev/sda3
  * mount filesystems
    * swapon /dev/disk/by-label/myswap
    * mount -o async,relatime,noauto,rw,suid,dev,exec,nouser,loud,ssd,autodefrag,compress-force=lzo,datasum,datacow,space_cache,commit=300,enospc_debug,discard /dev/disk/by-label/myroot /mnt
  * network is already set... (dhcp)
    * set static? #TODO:
    * test internet works
      * ping 8.8.8.8
      * ping google.com
  * set configuration.nix
    * nixos-generate-config --root /mnt
    * mv /mnt/etc/nixos/configuration.nix /mnt/etc/nixos/configuration.nix.generated
      \ as a backup
    * get vim and mc
      * time nix-env -i vim mc
        \ vim takes: 24.5 sec
        \ vim: 47.4s
        \ mc takes: 58s
    * to mount vboxsf shares while booted from the iso (in order to get your config into virtualbox!)
      * vim /etc/nixos/configuration.nix
        \ virtualisation.virtualbox.guest.enable = true;
        \ #services.gpm.enable = true; #no effect!
        \ #because we want to see if copy/paste is available! this doesn't start gpm.service and manually starting it via systemctl start gpm.service hangs!! #FIXME:!  after like 3min of hang, journalctl -xe  reports it was waiting for dev-input-mice.device which failed!
        \ wq! (because it's readonly!)
      * time nixos-rebuild switch
        \ 12m54s (virtualbox)
        \ 27m22s(virtualbox 4 cores KVM) a few days later
        \ 24m17s(4cpus)
        \ 18m39s(2cpus)
        \ 24m20s(3cpus)
      * now you must find 2 modules
        * cd $(dirname `find /nix/store/ -iname vboxsf\* | grep shrunk`)
        \ should be: /nix/store/hashhere-kernel-modules-shrunk/lib/modules/4.4.8/misc/vboxsf.ko
        \ cd $thatdir
        * insmod vboxguest.ko ; insmod vboxsf.ko
      * mkdir /vmsh
      * now you can mount
        \ mount -t vboxsf vmsharedfolder /vmsh
    * cp -a /vmsh/configuration.nix /mnt/etc/nixos/
    * cp -a /vmsh/prep /mnt/etc/nixos/
    * cd /mnt/etc/nixos
    * ./prep
      \ this also git clones the nixpkgs repo under nixpkgs folder! because it does 'nix-env wget git' (internally)
      \ that reset it to 16.03 stable channel!
      - prep already does this:
        * cd nixpkgs
        - git reset --hard origin/master
          \ now it's just like newly cloned
          \ this takes 2 days to compile! avoid using master!
        * git reset --hard channels/nixos-16.03
          \ stable!
        * cd ..
    * edit the hdd id for grub boot
      * ls -la /dev/disk/by-id/
        \ see the one with /dev/sda
        \ put it in configuration.nix under /dev/disk/by-id/...
      * vim /mnt/etc/nixos/configuration.nix
    * setterm --powerdown 0 --blank 0 --powersave off
      \ to prevent the term from getting black and then not seeing why/where it crashed!
    * time NIX_PATH="nixpkgs=/mnt/etc/nixos/nixpkgs" SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt" nixos-install --option binary-caches-parallel-connections 3
      \ //crashed virtualbox with guru meditation after a while!(without KVM in kernel)
      \ gettext, binutils and anything from ftpmirror.gnu.org ... is slow max 190KB/sec
      \ can't use the path without /mnt ! and can't use nixos-install without setting NIX_PATH because it ignores the nixPath setting in the configuration.nix for wtw reason!
      \ this will take ages! if you're using master like that
      \ so, about 40 hours of continous compilation (4 cores KVM vbox!) for master branch!
      \ NOTE: for the ignored error 'Curl error 77' see: https://github.com/NixOS/nixpkgs/pull/15579#issuecomment-220638757 we're already using workaround with SSL_CERT_FILE above
      \ time: 25m until fail(newer kernel for old vbox 5.0.12), for channel/nixos-16.03 (21 may 2016) - depends on download speed!
      \ using --option binary-caches-parallel-connections 3  because to avoid this: https://github.com/NixOS/nixpkgs/issues/14874#issuecomment-220774656   NO EFFECT!!!!! that 'still waiting for ... after 5 seconds' still happens!!! JFC!
      * cd /etc/nixos/nixpkgs
      * git fetch --all
        \ to at least update the channels/!
      * git reset --hard channels/nixos-unstable
      - git cherry-pick 4f5e4ad69 fde921578a -n
        \ to update virtualbox from 5.0.14 to 5.0.20 else it won't compile with kernel 4.5/4.6
        \ it's already in!!!
      * now do the above nixos-install command! again
        \ time: 18m1s + 11m12s
        \ (3cores) 24min + 22min
    * sync
    * umount /mnt
      \ yes this works! (won't work in GuixSD though, as comparison!)
    * sync
    * reboot
    * remove CD from virtualbox drive! else it boots from it
      \ FIXME: perhaps if we set any partition as bootable, it won't boot from CD?

